<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{fragments/common :: head}"></head>
<body>
  <div class="portletBody container-fluid">
    <div th:replace="~{fragments/common :: menu('list')}"></div>

    <div th:if="${alert}" class="sak-banner-warn" role="alert" th:text="${alert}">Alert</div>
    <div th:if="${success}" class="sak-banner-success" role="status" th:text="${success}">Success</div>

    <h1 class="h4 mb-3" th:text="#{poll_vote_title}">Vote</h1>
    <p class="fw-semibold" th:utext="${poll.text}">Poll question</p>
    <div class="mb-3" th:utext="${poll.description}"></div>

    <form th:action="@{/voteQuestion}" th:object="${voteForm}" method="post" class="d-grid gap-3">
      <input type="hidden" th:field="*{pollId}" />
      <div class="list-group" th:if="${options}">
        <label th:each="option : ${options}" class="list-group-item d-flex align-items-center gap-3">
          <input th:type="${multipleChoice} ? 'checkbox' : 'radio'"
                 class="me-2"
                 name="selectedOptionIds"
                 th:id="${'option-' + option.id}"
                 th:value="${option.id}"
                 th:checked="${#lists.contains(voteForm.selectedOptionIds, option.id)}" />
          <span class="flex-grow-1" th:utext="${option.text}">Option text</span>
        </label>
      </div>

      <div class="act">
        <input type="submit" class="active" th:value="#{vote_vote}" value="Vote" />
        <input type="reset" th:value="#{vote_reset}" value="Reset" />
        <input type="button" th:onclick="|location.href='@{/votePolls}'|" th:value="#{vote_cancel}" value="Cancel" />
      </div>
    </form>
  </div>
</body>
</html>
